<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <?= $this->headTitle(SITE_TITLE) ?>
        <link rel="icon" type="image/png" href="<?= TEMPLATE ?>/favicon.png" />
        <link href="<?= TEMPLATE ?>/style.css" media="screen" rel="stylesheet" type="text/css" />
        <link href="<?= SITE_URL . '/js/ui/jquery-ui.css' ?>" media="screen" rel="stylesheet" type="text/css" />
        <link href="<?= SITE_URL . '/js/elfinder/css/elfinder.css' ?>" media="screen" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
        <script type="text/javascript" src="<?= SITE_URL . '/js/tiny_mce/jquery.tinymce.js' ?>"></script>
        <script type="text/javascript" src="<?= SITE_URL . '/js/elfinder/js/elfinder.min.js' ?>"></script>
        <script type="text/javascript" src="<?= SITE_URL . '/js/elfinder/js/i18n/elfinder.ru.js' ?>"></script>
        <script type="text/javascript" src="<?= SITE_URL . '/js/editarea/edit_area_full.js' ?>"></script>
        <script type="text/javascript" src="<?= SITE_URL . '/js/jquery.form.js' ?>"></script>
        <script type="text/javascript" src="<?= SITE_URL . '/js/jquery.treeview.js' ?>"></script>
        <script type="text/javascript" src="<?= SITE_URL . '/js/jquery.tablesorter.js' ?>"></script>
        <script type="text/javascript" src="<?= SITE_URL . '/js/jquery.tablesorter.pager.js' ?>"></script>
        <script type="text/javascript" src="<?= SITE_URL . '/js/jquery.tablesorter.filter.js' ?>"></script>
        <script type="text/javascript" src="<?= SITE_URL . '/js/jquery.imgpreview.js' ?>"></script>
        <script type="text/javascript" src="<?= SITE_URL . '/js/jquery.easytooltip.js' ?>"></script>

        <script type="text/javascript">
            /*Editor JS*/
            editAreaLoader.init({
                id : "editarea_js",		// textarea id
                syntax: "js",			// syntax to be uses for highgliting
                start_highlight: true,		// to display with highlight mode on start-up
                language: "<?= LANGUAGE ?>",
                syntax_selection_allow: "js",
                toolbar: "search, go_to_line, |, undo, redo, |, fullscreen, change_smooth_selection, highlight, reset_highlight, word_wrap, |, help",
                allow_toggle: false
            });

            /*Editor PHP*/
            editAreaLoader.init({
                id : "editarea",		// textarea id
                syntax: "php",			// syntax to be uses for highgliting
                start_highlight: true,		// to display with highlight mode on start-up
                language: "<?= LANGUAGE ?>",
                syntax_selection_allow: "php",
                replace_tab_by_spaces: 4,
                toolbar: "search, go_to_line, |, undo, redo, |, fullscreen, change_smooth_selection, highlight, reset_highlight, word_wrap, |, help",
                allow_toggle: false
            });
            $().ready(function() {
                
            
	
                xOffset = 10;
                yOffset = 10;

                $("a.imgpreview").hover(function(e){
                    $("body").append("<div id='imgpreview'><img src='"+ this.rel +"' alt='url preview' /></div>");								 
                    $("#imgpreview").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px").fadeIn("fast");	
                },
                function(){
                    $("#imgpreview").remove();
                });	
                    
                $("a.imgpreview").mousemove(function(e){
                    $("#imgpreview").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px");
                });			

                $("table.sortable")
                .tablesorter({widthFixed: true, widgets: ['zebra']})
                .tablesorterPager({container: $("#sortablepager")})
                .tablesorterFilter({filterContainer: "#sortable-filter-box",
                    filterClearContainer: "#sortable-filter-clear-button"
                });
                        
                $(".tooltip").hover(function(){
                    $(this).easyTooltip({
                        useElement: $(this).attr("rel")
                    });
                });
                 
                /*TinyMCE*/
                $('.tinymce').tinymce({
                    script_url : '<?= SITE_URL ?>/js/tiny_mce/tiny_mce.js',
                    theme : "advanced",
                    plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",
                    language : "<?= LANGUAGE ?>",
                    // Theme options
                    theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
                    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
                    theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
                    theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
                    theme_advanced_toolbar_location : "top",
                    theme_advanced_toolbar_align : "left",
                    theme_advanced_statusbar_location : "bottom",
                    theme_advanced_resizing : true,
                    remove_script_host : true,
                    relative_urls : false,
                    document_base_url : "<?= SITE_URL ?>",
                    convert_urls : false,
                    //Google maps
                    extended_valid_elements : 'iframe[width|height|frameborder|scrolling|marginheight|marginwidth|src]',
                    content_css : "<?= SITE_URL . '/css/editor.css' ?>",
                    // Drop lists for link/image/media/template dialogs
                    external_link_list_url : "<?= ADMIN_URL ?>/pages/links",
                    /*template_external_list_url : "lists/template_list.js",
                                                            external_image_list_url : "lists/image_list.js",
                                                            media_external_list_url : "lists/media_list.js",
                     */
                    file_browser_callback : function(field_name, url, type, win) {
                        var w = window.open(<?= "'" . ADMIN_URL . "/files'" ?>, null, 'width=600,height=500');
                        w.tinymceFileField = field_name;
                        w.tinymceFileWin = win;
                    }
                });

                /*Filemanager*/
                $('.file_fm').dblclick(function() {
                    var id = $(this).attr('id');
                    load_elfinder(id);
                });

                $('.file_fm').parent().append('<a href="" class="file_button"></a>');

                /*
                                                        $('.dropdown li ul').hide();
                                                        $('.dropdown li').hover(null, function(){$(this).find('ul').hide();});
                                                        $('#logotype').click(function(){if ($('.dropdown li ul').attr('style') == 'display: none;'){$('.dropdown li ul').show();}else{$('.dropdown li ul').hide();}});
                 */

                $('.filemanager').click(function() {
                    var id = $(this).attr('id');
                    load_elfinder(id);
                });

                /*Pick date*/
                $(".datepicker").datepicker({
                    altFormat: 'yy-mm-dd',
                    dateFormat: 'dd.mm.yy',
                    dayNamesMin: ['<?= $this->t->_('Su') ?>', '<?= $this->t->_('Mo') ?>', '<?= $this->t->_('Tu') ?>', '<?= $this->t->_('We') ?>', '<?= $this->t->_('Th') ?>', '<?= $this->t->_('Fr') ?>', '<?= $this->t->_('Sa') ?>'],
                    monthNames: ['<?= $this->t->_('January') ?>','<?= $this->t->_('February') ?>','<?= $this->t->_('March') ?>','<?= $this->t->_('April') ?>','<?= $this->t->_('May') ?>','<?= $this->t->_('June') ?>','<?= $this->t->_('July') ?>','<?= $this->t->_('August') ?>','<?= $this->t->_('September') ?>','<?= $this->t->_('October') ?>','<?= $this->t->_('November') ?>','<?= $this->t->_('December') ?>']
                });
                
                /*Help system*/
                $("dd:has(ul.errors)").children("p.description").hide().prevAll('ul.errors').before('<a href="#" class="help_link">help</a>');
                $("dd:not(:has(ul.errors))").children("p.description").hide().before('<a href="#" class="help_link">help</a>');                
                $("a.help_link").click(function(){
                    $('#dialog').html($(this).nextAll("p.description").html());
                    $('#dialog').dialog({
                        modal:true,
                        title: $(this).parent().prev('dt').children('label').html()
                    });
                    return false;
                });

                /*Hide navigation*/
                $("ul.dropdown li ul").hide();
                $("ul.dropdown li").hover(
                function () {
                    $(this).children('ul').show('slow');
                },
                function () {
                    $('> a',this).nextAll().hide();
                }
                
               
            );
                    
                
                
                $('.delete_button').click(function() {
                    url = $(this).attr("href");
                    $("#dialog").dialog("destroy");
                    $("#dialog").empty();
                    $("#dialog").append('<?= $this->t->_('Are you sure you want to delete this Resource?') ?>')
                    $("#dialog").dialog({
                        title: '<?= $this->t->_('Removing') ?>',
                        modal: true,
                        buttons: {
                            '<?= $this->t->_('Delete') ?>': function() {
                                location.href = url;
                            },
                            '<?= $this->t->_('Cancel') ?>': function() {
                                $(this).dialog('close');
                            }
                        }
                    });

                });

            });

            /*Fileexplorer*/
            function load_elfinder($id) {
                $('<div />').elfinder({
                    url : <?= "'" . ADMIN_URL . "/files/connector/'" ?>,
                    lang : '<?= LANGUAGE ?>',
                    dialog : { width : 900, modal : true },

                    editorCallback : function(url) {
                        if(window.tinymceFileField){
                            window.tinymceFileWin.document.forms[0].elements[window.tinymceFileField].value = url;
                            window.tinymceFileWin.focus();
                        } else {
                            document.getElementById($id).value = url;
                        }
                        window.close();
                    }

                });

            };
                        
        </script>
        <?= $this->headScript(); ?>
    </head>
    <body>
        <div id="wrap">
            <div id="header">
                <div id="hlb"></div>
                <div id="hcb"></div>
                <div id="hrb"></div>
            </div>
            <div id="content">
                <div id="page">
                    <div id="page_header">
                        <?php
                        $session = new Zend_Session_Namespace('UnCMS');
                        if (isset($session->acl->settings)) {
                            $version = explode('.', $this->config->version);
                            $update = explode('.', $this->config->update);
                            if (((int) $version[0] < (int) $update[0]) || ((int) $version[0] == (int) $update[0] && (int) $version[1] < (int) $update[1]) || ((int) $version[0] == (int) $update[0] && (int) $version[1] == (int) $update[1] && (int) $version[2] < (int) $update[2])) {
                            ?>
                            <div id="newversion"><a href="<?= ADMIN_URL ?>/settings/update" title="<?= $this->t->_('Available new version') ?>"><?= $this->t->_('Available new version') . ': ' . $this->config->update ?></a></div>
                        <?php } } ?>
                        <div id="page_title">
                            <?php
                            $i = 0;
                            $col = count($this->navigation_line);
                            foreach ($this->navigation_line as $key => $val) {
                                $i++;
                                if ($col == $i) {
                                    $class = 'nav_line_last';
                                } else {
                                    $class = 'nav_line';
                                }
                                $nav = '<a href="' . $val . '" class="' . $class . '">' . $key . '</a>';
                                echo($nav);
                            }
                            ?>
                        </div>
                    </div>
                    <div id="ajax_content">
                        <?= $this->layout()->content ?>
                    </div>
                    <div class="clear"></div>
                    <p><br /><br /></p>
                </div>
            </div>
        </div>
        <div id="footer">
            <div id="footer-content">
                <div id="flb"></div>
                <div id="fcb">
                    <div id="copyline"><a href="http://www.unlabeled.ru">Unlabeled CMS</a>  is released under the <a href="http://www.gnu.org/licenses/gpl.html" target="_blank">GNU General Public License</a>.</div>
                </div>
                <div id="frb"></div>
            </div>
        </div>       
        <div id="navigation">
            <ul class="dropdown">
                <li><a href="<?= ADMIN_URL ?>/events" class="i_event" title="<?= $this->t->_('Events') ?>"><span><?= $this->t->_('Events') ?></span></a></li>
                <?php
                if (isset($session->acl->files)) {
                    ?>
                    <li><a href="#" class="filemanager i_filemanager" title="<?= $this->t->_('Files') ?>"><span><?= $this->t->_('Files') ?></span></a></li>
                <?php } if (isset($session->acl->snippet)) { ?>
                    <li><a href="<?= ADMIN_URL ?>/snippet" class="i_snippet" title="<?= $this->t->_('Snippets') ?>"><span><?= $this->t->_('Snippets') ?></span></a></li>
                <?php } if (isset($session->acl->forms)) { ?>
                    <li><a href="<?= ADMIN_URL ?>/forms" class="i_forms" title="<?= $this->t->_('Forms') ?>"><span><?= $this->t->_('Forms') ?></span></a></li>
                <?php } if (isset($session->acl->references)) { ?>
                    <li><a href="<?= ADMIN_URL ?>/references" class="i_references" title="<?= $this->t->_('References') ?>"><span><?= $this->t->_('References') ?></span></a></li>
                <?php } if (isset($session->acl->addons)) { ?>
                    <li><a href="<?= ADMIN_URL ?>/addons" class="i_addons" title="<?= $this->t->_('Addons'); ?>"><span><?= $this->t->_('Addons'); ?></span></a></li>
                <?php } if (isset($session->acl->users)) { ?>
                    <li><a href="<?= ADMIN_URL ?>/acl" class="i_acl" title="<?= $this->t->_('Access'); ?>"><span><?= $this->t->_('Access'); ?></span></a></li>
                <?php } if (isset($session->acl->settings)) { ?>
                    <li><a href="<?= ADMIN_URL ?>/settings" class="i_settings" title="<?= $this->t->_('Settings') ?>"><span><?= $this->t->_('Settings') ?></span></a></li>
                    <li><a href="<?= ADMIN_URL ?>/settings/backups" class="i_database" title="<?= $this->t->_('Backups') ?>"><span><?= $this->t->_('Backups') ?></span></a></li>
                    <?php
                }
                if (!isset($this->view_page_url)) {
                    $site_url = SITE_URL;
                } else {
                    $site_url = $this->view_page_url;
                }
                ?>
                <li><a href="<?= $site_url ?>" target="_blank" class="i_view" title="<?= $this->t->_('View') ?>"><span><?= $this->t->_('View') ?></span></a></li>
            </ul>
        </div>
        <div id="logo">
            <a href="<?= ADMIN_URL ?>" id="logotype" title="Unlabeled CMS"><span></span></a>
        </div>
        <div id="nav"><a href="<?= ADMIN_URL ?>/acl/user" title="<?= $this->t->_('Edit profile') ?>"><?= $this->user->name ?></a> (<a href="<?= ADMIN_URL ?>/acl/exit" class="exit_link" title="<?= $this->t->_('Exit') ?>"> <?= $this->t->_('Exit') ?> </a>)</div>
        <div id="dialog"></div>
        <div class="tooltips"></div>
    </body>
</html>

